package com.jzo2o.customer.controller.worker;

import cn.hutool.core.bean.BeanUtil;
import com.jzo2o.customer.model.domain.BankAccount;
import com.jzo2o.customer.model.dto.request.BankAccountUpsertReqDTO;
import com.jzo2o.customer.service.BankAccountService;
import com.jzo2o.mvc.utils.UserContext;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("workerBankAccountController")
@RequestMapping("/worker/bank-account")
@Api(tags = "服务端 - 服务端设置银行账户接口设计")
public class BankAccountController {
    @Autowired
    private BankAccountService bankAccountService;

    @PostMapping()
    @ApiOperation("新增或更新银行账号信息接口")
    public void addupt(@RequestBody BankAccountUpsertReqDTO dto) {
     bankAccountService.addupt(dto);
    }
    @GetMapping("/currentUserBankAccount")
    @ApiOperation("新增或更新银行账号信息接口")
    public  BankAccountUpsertReqDTO getCurrentUserBankAccount() {
        Long id = UserContext.currentUserId();
        BankAccount byId = bankAccountService.getById(id);
        return BeanUtil.toBean(byId, BankAccountUpsertReqDTO.class);

    }

}
